define(['egis'],
    function (egis) {
        Window.deserializer = Window.deserializer || new egis.core.Deserializer();
        Window.container = Window.container || {};
        var plotDeleteCommand = function (options) {
            options = options || {};
            egis.basic.DeleteElementCommand.call(this, options);
            this.plotPlugin = options.plotPlugin;
        }
        egis.core.ClassUtil.extend2(plotDeleteCommand, egis.basic.DeleteElementCommand);
        /***
         * 删除元素命令初始化
         * @param Object hook 初始化参数
         */
        plotDeleteCommand.prototype.onCreate = function (hook) {
            this.uber.onCreate.call(this, hook);
            this.plotPlugin = hook['plotPlugin'];
        }

        /***
         * 删除元素动作执行完成时触发，用来更新标绘视图
         * @param Layer layer 元素所在图层
         * @param ElementBase ele 元素
         */
        plotDeleteCommand.prototype.onDeleteElement = function (layer, ele) {
            if(!!this.plotPlugin)
                this.plotPlugin.removeElement(this, ele.id);
        }
        dsBridge.register('create_PlotDeleteCommand', function (sourceId, commandId, plotLayerId, plotPlugInId) {
            try {
                var plotLayer = Window.container[plotLayerId];
                var plotPlugIn = Window.container[plotPlugInId];
                var plotDeleteCmd = new plotDeleteCommand({
                    id: commandId,
                    layer: plotLayer,
                    plotPlugin: plotPlugIn
                });
                Window.container[sourceId] = plotDeleteCmd;
            }
            catch (e) {
                alert(e)
            }
        });

        dsBridge.register('PlotDeleteCommand_onClick', function (sourceId) {
            try {
                var plotDeleteCmd = Window.container[sourceId];
                if (!!plotDeleteCmd) {
                    plotDeleteCmd.onClick();
                }
            }
            catch (e) {
                alert(e)
            }
        });
    })